package com.lcx.movie.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lcx.movie.entity.ViewHistory;
import com.lcx.movie.mapper.ViewHistoryMapper;
import com.lcx.movie.service.ViewHistoryService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 李丽君
 * @version 1.0
 * @Description 浏览记录实现类
 * @date 2025/3/3 16:36
 */
@Service
public class ViewHistoryServiceImpl extends ServiceImpl<ViewHistoryMapper, ViewHistory> implements ViewHistoryService {
    @Autowired
    private ViewHistoryMapper viewHistoryMapper;
    /**
     * 新增浏览记录
     * @param viewHistory 浏览记录实体
     * @return 受影响的行数
     */
    @Override
    public int insertViewHistory(ViewHistory viewHistory){
        return viewHistoryMapper.insertViewHistory(viewHistory);
    }
    /**
     * 根据用户id查询浏览记录
     * @param userId 用户id
     * @return 浏览记录集合
     */
    @Override
    public List<ViewHistory> selectViewHistory(Integer userId){
        return viewHistoryMapper.selectViewHistory(userId);
    }

    /**
     * 根据浏览记录id移除浏览记录
     * @param viewId 浏览记录id
     * @return 受影响的行数
     */
    @Override
    public int deleteViewHistoryByViewId(Integer viewId){
        return viewHistoryMapper.deleteViewHistoryByViewId(viewId);
    }

    /**
     * 后台管理员查询浏览记录
     * @return 浏览记录集合
     */
    @Override
    public List<ViewHistory> manageSelectViewHistory(@Param("movieCnName") String movieCnName){
        return viewHistoryMapper.manageSelectViewHistory(movieCnName);
    }

}
